<!--
 * @Author: liujiachen liujiachen@neuedu.com
 * @Date: 2024-09-12 17:35:53
 * @LastEditors: liujiachen liujiachen@neuedu.com
 * @LastEditTime: 2024-09-15 19:48:11
 * @FilePath: \WWW\notepad\register.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Notepad</title>

    <!-- bootstrap -->
    <link rel="stylesheet" href="./assets/css/bootstrap.min.css" />
    <!-- 引用移动端MUI框架 -->
     <link rel="stylesheet" href="./assets/plugins/mui/css/mui.min.css">

    <!-- animate.css -->
    <link rel="stylesheet" href="./assets/css/animate.min.css" />

    <!-- 重置样式 -->
    <link rel="stylesheet" href="./assets/css/reset.css" />

    <!-- 公共样式 -->
    <link rel="stylesheet" href="./assets/css/common.css" />

    <!-- 页面独立的 -->
    <link rel="stylesheet" href="./assets/css/UserLogin.css" />
</head>
<body>
    <!-- 用户信息 -->
    <div class="user">
        <div class="avatar wow fadeInUp">
            <img src="./assets/images/avatar.png" />
        </div>

        <div class="notice wow fadeInUp" data-wow-delay="100ms">注册页面</div>
    </div>

    <form id="register" method="post" class="login wow fadeInUp" data-wow-delay="200ms">
        <div class="form-group">
            <label for="mobile">手机号</label>
            <input type="text" class="form-control" id="mobile" placeholder="请输入手机号" required />
        </div>

        <div class="form-group">
            <label for="password">密码</label>
            <input type="password" class="form-control" id="password" placeholder="请输入密码"  />
        </div>
        <!-- required 只是表单的一个输入验证，并不是说什么都不输入就不能点提交按钮，想要不输入的时候就不提交可以在提交按钮用ng-disabled来定义一下 -->
        <div class="action">
            <button type="submit" class="btn">注册登录</button>
        </div>
    </form>
</body>
</html>
<!-- jquery  -->
<script src="./assets/js/jquery.min.js"></script>

<!-- bootstrap 一般应用于PC端的框架-->
<script src="./assets/js/bootstrap.min.js"></script>
<!-- MUI移动段的框架 -->
 <script src="./assets/plugins/mui/js/mui.min.js"></script>

<!-- wow.js -->
<script src="./assets/js/wow.min.js"></script>
<!-- 引入axios -->
<script src="./assets/plugins/axios/axios.min.js"></script>
<script src="./assets/plugins/axios/request.js"></script>


<script>
    //实例化wow.js
    new WOW().init()
    //做移动端的注册界面 表单提交部分 MUI框架 引入MUI框架后 写
    $("#register").submit(async function(e){
        //阻止默认行为
        e.preventDefault();
        //获取手机号的输入值
         var mobile = $.trim($("#mobile").val());
         var password = $.trim($("#password").val());
        // 正则判断
        var res = /^1[3-9]\d{9}/;
        if(!res.test(mobile))
        {
            // mui.toast();自动消失
            mui.alert('手机号码格式不正确','注册提醒',['确认']);
            return false;
        }
        if(!password)
        {
            mui.alert('请输入密码!');
            return false;
        }
        //整合
        // var data = {mobile,password};
        // console.log(data);
        //发送同步请求
        var result = await POST({
            //
            url:'/business/login',
            params:{mobile,password}
        })
        if(result.code){
            //注册成功！ 跳转到登录界面
            mui.toast(result.msg)
            //定时跳转
            setTimeout(()=>location.href = 'login.html',2000)  
            return false;
        }else{
            //注册失败！
            mui.toast(result.msg)
            return false;
        }
    })

</script>